package com.hqyj.controller;


import com.hqyj.exception.R;
import com.hqyj.pojo.GoodsQueryParameter;
import com.hqyj.service.GoodsInfoService;
import com.hqyj.service.TestRedisService;
import com.hqyj.service.TestStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author rock
 * @since 2023-02-03 09:50:32
 */
@RestController
@RequestMapping("/goods-info")
public class GoodsInfoController {

    @Autowired
    GoodsInfoService goodsInfoService;

    //查询商品首页信息
    @GetMapping("/goods")
    public R queryGoodsInfoForm(){
        return goodsInfoService.queryGoodsInfoForm();
    }

    //查询热卖商品和限时特卖商品
    @GetMapping("/goods/1")
    public R queryGoodsInfoByGoodsTypeId(GoodsQueryParameter parameter) {
        return goodsInfoService.queryGoodsInfoByGoodsTypeId(parameter);
    }

    @Autowired
    TestRedisService redisService;



    //测试并发案例
    @GetMapping("/goods/2")
    public R test(Integer num,Integer shopId) {
        return redisService.buyShop(num,shopId);
    }

}

